package jsyf.oa.entity.contract;

import com.alibaba.fastjson.JSONObject;
import jsyf.oa.ientity.BaseEntity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name = "T_CON_REPAYMENT", schema = "oa", catalog = "")
public class RepaymentEntity extends BaseEntity implements Serializable {

    private String mainId = "";
    private Integer type = 0; //0-内部分期 1-融资
    private String repaymentDate = "";//还款日期
    private String remark = "";//备注
    private BigDecimal total = new BigDecimal("0.00");//本息合计
    private BigDecimal principal = new BigDecimal("0.00");//本金
    private BigDecimal interest = new BigDecimal("0.00");//利息
    private Integer sortNo = 0;
    private Integer haveSettle = 0;
    private String actualRepaymentDate = "";//实际还款日期
    private BigDecimal repaymentAmount = new BigDecimal("0.00");//还款金额
    private BigDecimal overduePenalty = new BigDecimal("0.00");//逾期罚息
    private BigDecimal remainingArrears = new BigDecimal("0.00");//剩余欠款
    private BigDecimal contractRepaymentAmount = new BigDecimal("0.00");//约定还款金额(融资款跟踪)
    private BigDecimal gsPenalty = new BigDecimal("0.00");//公司实收罚息
    private BigDecimal jroverduePenalty = new BigDecimal("0.00");//金融公司逾期罚息
    private BigDecimal jrPenalty = new BigDecimal("0.00");//金融公司实收罚息
    private String repaymentAttachName = "";
    private String repaymentAttachUrl = "";
    private String parentId = "0";
    private String financingDate = "";//  `FINANCING_DATE`
    private BigDecimal financingMoney = new BigDecimal("0.00");//   `FINANCING_MONEY`
    private String advancesDate = "";
    private BigDecimal advancesMoney = new BigDecimal("0.00");
    private BigDecimal cdRemainingArrears = new BigDecimal("0.00");
    private BigDecimal cdOverduePenalty = new BigDecimal("0.00");
    private BigDecimal everyRemainingArrear = new BigDecimal("0.00");
    private BigDecimal overduePenaltyTotal = new BigDecimal("0.00");
    private Integer hkType =1;
    private String createUserId;
    private String createUserName;
    private String createDate;
    private BigDecimal everyOverduePenalty=new BigDecimal("0.00");

    //免罚息相关字段
    private String interestFreeAttachName;//免息凭证
    private String interestFreeAttachUrl;
    private Integer interestFreeFlag=0;//是否免息，0默认，1是免息的，2是提交申请免息，正在审核中的状态
    private String interestFreeReason;//免息原因
    private BigDecimal freeMoney; //免息金额


    public String getInterestFreeAttachName() {
        return interestFreeAttachName;
    }

    public void setInterestFreeAttachName(String interestFreeAttachName) {
        this.interestFreeAttachName = interestFreeAttachName;
    }

    public String getInterestFreeAttachUrl() {
        return interestFreeAttachUrl;
    }

    public void setInterestFreeAttachUrl(String interestFreeAttachUrl) {
        this.interestFreeAttachUrl = interestFreeAttachUrl;
    }

    public Integer getInterestFreeFlag() {
        return interestFreeFlag;
    }

    public void setInterestFreeFlag(Integer interestFreeFlag) {
        this.interestFreeFlag = interestFreeFlag;
    }

    public String getInterestFreeReason() {
        return interestFreeReason;
    }

    public void setInterestFreeReason(String interestFreeReason) {
        this.interestFreeReason = interestFreeReason;
    }

    public BigDecimal getEveryOverduePenalty() {
        return everyOverduePenalty;
    }

    public void setEveryOverduePenalty(BigDecimal everyOverduePenalty) {
        this.everyOverduePenalty = everyOverduePenalty;
    }

    public Integer getHkType() {
        return hkType;
    }

    public void setHkType(Integer hkType) {
        this.hkType = hkType;
    }

    private List<RepaymentEntity> repaymentParentList;//跟踪列表再套list

    public BigDecimal getOverduePenaltyTotal() {
        return overduePenaltyTotal;
    }

    public void setOverduePenaltyTotal(BigDecimal overduePenaltyTotal) {
        this.overduePenaltyTotal = overduePenaltyTotal;
    }

    public BigDecimal getEveryRemainingArrear() {
        return everyRemainingArrear;
    }

    public void setEveryRemainingArrear(BigDecimal everyRemainingArrear) {
        this.everyRemainingArrear = everyRemainingArrear;
    }

    public BigDecimal getCdRemainingArrears() {
        return cdRemainingArrears;
    }

    public void setCdRemainingArrears(BigDecimal cdRemainingArrears) {
        this.cdRemainingArrears = cdRemainingArrears;
    }

    public BigDecimal getCdOverduePenalty() {
        return cdOverduePenalty;
    }

    public void setCdOverduePenalty(BigDecimal cdOverduePenalty) {
        this.cdOverduePenalty = cdOverduePenalty;
    }

    public BigDecimal getGsPenalty() {
        return gsPenalty;
    }

    public void setGsPenalty(BigDecimal gsPenalty) {
        this.gsPenalty = gsPenalty;
    }

    public BigDecimal getJroverduePenalty() {
        return jroverduePenalty;
    }

    public void setJroverduePenalty(BigDecimal jroverduePenalty) {
        this.jroverduePenalty = jroverduePenalty;
    }

    public BigDecimal getJrPenalty() {
        return jrPenalty;
    }

    public void setJrPenalty(BigDecimal jrPenalty) {
        this.jrPenalty = jrPenalty;
    }

    public String getAdvancesDate() {
        return advancesDate;
    }

    public void setAdvancesDate(String advancesDate) {
        this.advancesDate = advancesDate;
    }

    public BigDecimal getAdvancesMoney() {
        return advancesMoney;
    }

    public void setAdvancesMoney(BigDecimal advancesMoney) {
        this.advancesMoney = advancesMoney;
    }

    public String getFinancingDate() {
        return financingDate;
    }

    public void setFinancingDate(String financingDate) {
        this.financingDate = financingDate;
    }

    public BigDecimal getFinancingMoney() {
        return financingMoney;
    }

    public void setFinancingMoney(BigDecimal financingMoney) {
        this.financingMoney = financingMoney;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getHaveSettle() {
        return haveSettle;
    }

    public void setHaveSettle(Integer haveSettle) {
        this.haveSettle = haveSettle;
    }

    public BigDecimal getContractRepaymentAmount() {
        return contractRepaymentAmount;
    }

    public void setContractRepaymentAmount(BigDecimal contractRepaymentAmount) {
        this.contractRepaymentAmount = contractRepaymentAmount;
    }

    public String getActualRepaymentDate() {
        return actualRepaymentDate;
    }

    public void setActualRepaymentDate(String actualRepaymentDate) {
        this.actualRepaymentDate = actualRepaymentDate;
    }

    public BigDecimal getRepaymentAmount() {
        return repaymentAmount;
    }

    public void setRepaymentAmount(BigDecimal repaymentAmount) {
        this.repaymentAmount = repaymentAmount;
    }

    public BigDecimal getOverduePenalty() {
        return overduePenalty;
    }

    public void setOverduePenalty(BigDecimal overduePenalty) {
        this.overduePenalty = overduePenalty;
    }

    public BigDecimal getRemainingArrears() {
        return remainingArrears;
    }

    public void setRemainingArrears(BigDecimal remainingArrears) {
        this.remainingArrears = remainingArrears;
    }

    public Integer getSortNo() {
        return sortNo;
    }

    public void setSortNo(Integer sortNo) {
        this.sortNo = sortNo;
    }

    public String getMainId() {
        return mainId;
    }

    public void setMainId(String mainId) {
        this.mainId = mainId;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getRepaymentDate() {
        return repaymentDate;
    }

    public void setRepaymentDate(String repaymentDate) {
        this.repaymentDate = repaymentDate;
    }

    public BigDecimal getTotal() {
        return total;
    }

    public void setTotal(BigDecimal total) {
        this.total = total;
    }

    public BigDecimal getPrincipal() {
        return principal;
    }

    public void setPrincipal(BigDecimal principal) {
        this.principal = principal;
    }

    public BigDecimal getInterest() {
        return interest;
    }

    public void setInterest(BigDecimal interest) {
        this.interest = interest;
    }

    public String getRepaymentAttachName() {
        return repaymentAttachName;
    }

    public void setRepaymentAttachName(String repaymentAttachName) {
        this.repaymentAttachName = repaymentAttachName;
    }

    public String getRepaymentAttachUrl() {
        return repaymentAttachUrl;
    }

    public void setRepaymentAttachUrl(String repaymentAttachUrl) {
        this.repaymentAttachUrl = repaymentAttachUrl;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public List<RepaymentEntity> getRepaymentParentList() {
        return repaymentParentList;
    }

    public void setRepaymentParentList(List<RepaymentEntity> repaymentParentList) {
        this.repaymentParentList = repaymentParentList;
    }

    public String getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(String createUserId) {
        this.createUserId = createUserId;
    }

    public String getCreateUserName() {
        return createUserName;
    }

    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }

    public String getCreateDate() {
        return createDate;
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }

    public BigDecimal getFreeMoney() {
        return freeMoney;
    }

    public void setFreeMoney(BigDecimal freeMoney) {
        this.freeMoney = freeMoney;
    }

    @Override
    public JSONObject getJSONObject() {
        JSONObject obj = new JSONObject();
        obj.put("ID", getId());
        obj.put("REPAYMENT_DATE", getRepaymentDate());
        obj.put("TOTAL", getTotal());
        obj.put("PRINCIPAL", getPrincipal());
        obj.put("INTEREST", getInterest());
        obj.put("MAIN_ID", getMainId());
        obj.put("TYPE", getType());
        obj.put("SORT_NO", getSortNo());
        obj.put("ACTUAL_REPAYMENT_DATE", getActualRepaymentDate());
        obj.put("REPAYMENT_AMOUNT", getRepaymentAmount());
        obj.put("OVERDUE_PENALTY", getOverduePenalty());
        obj.put("REMAINING_ARREARS", getRemainingArrears());
        obj.put("CONTRACT_REPAYMENT_AMOUNT", getContractRepaymentAmount());
        obj.put("HAVE_SETTLE", getHaveSettle());
        obj.put("REMARK", getRemark());
        obj.put("REPAYMENT_ATTACH_NAME", getRepaymentAttachName());
        obj.put("REPAYMENT_ATTACH_URL", getRepaymentAttachUrl());
        obj.put("PARENT_ID", getParentId());
        obj.put("GS_PENALTY", getGsPenalty());
        obj.put("JR_OVERDUE_PENALTY", getJroverduePenalty());
        obj.put("JR_PENALTY", getJrPenalty());
        obj.put("CD_REMAINING_ARREARS", getCdRemainingArrears());
        obj.put("CD_OVERDUE_PENALTY", getCdOverduePenalty());
        obj.put("CREATE_USER_ID", getCreateUserId());
        obj.put("CREATE_USER_NAME", getCreateUserName());
        obj.put("CREATE_DATE", getCreateDate());
        obj.put("CREATE_TIME", getCreateTime());
        obj.put("OVERDUE_PENALTY_TOTAL", getOverduePenaltyTotal());
        obj.put("HK_TYPE", getHkType());
        obj.put("INTEREST_FREE_ATTACH_NAME", getInterestFreeAttachName());
        obj.put("INTEREST_FREE_ATTACH_URL",getInterestFreeAttachUrl());
        obj.put("INTEREST_FREE_FLAG", getInterestFreeFlag());
        obj.put("INTEREST_FREE_REASON",getInterestFreeReason());
        obj.put("FREE_MONEY",getFreeMoney());
        return obj;
    }

    @Override
    public String getTableName() {
        return "t_con_repayment";
    }

    @Override
    public JSONObject getJSONColumns() {
        JSONObject obj = new JSONObject();
        obj.put("ID", "id");
        obj.put("MAIN_ID", "mainId");
        obj.put("REPAYMENT_DATE", "repaymentDate");
        obj.put("TOTAL", "total");
        obj.put("PRINCIPAL", "principal");
        obj.put("INTEREST", "interest");
        obj.put("TYPE", "type");
        obj.put("SORT_NO", "sortNo");
        obj.put("ACTUAL_REPAYMENT_DATE", "actualRepaymentDate");
        obj.put("REPAYMENT_AMOUNT", "repaymentAmount");
        obj.put("OVERDUE_PENALTY", "overduePenalty");
        obj.put("REMAINING_ARREARS", "remainingArrears");
        obj.put("CONTRACT_REPAYMENT_AMOUNT", "contractRepaymentAmount");
        obj.put("HAVE_SETTLE", "haveSettle");
        obj.put("REMARK", "remark");
        obj.put("REPAYMENT_ATTACH_NAME", "repaymentAttachName");
        obj.put("REPAYMENT_ATTACH_URL", "repaymentAttachUrl");
        obj.put("PARENT_ID", "parentId");
        obj.put("GS_PENALTY", "gsPenalty");
        obj.put("JR_OVERDUE_PENALTY", "jroverduePenalty");
        obj.put("JR_PENALTY", "jrPenalty");
        obj.put("CD_REMAINING_ARREARS", "cdRemainingArrears");
        obj.put("CD_OVERDUE_PENALTY", "cdOverduePenalty");
        obj.put("CREATE_USER_ID", "createUserId");
        obj.put("CREATE_USER_NAME", "createUserName");
        obj.put("CREATE_DATE", "createDate");
        obj.put("CREATE_TIME", "createTime");
        obj.put("OVERDUE_PENALTY_TOTAL", "overduePenaltyTotal");
        obj.put("HK_TYPE", "hkType");
        obj.put("INTEREST_FREE_ATTACH_NAME", "interestFreeAttachName");
        obj.put("INTEREST_FREE_ATTACH_URL","interestFreeAttachUrl");
        obj.put("INTEREST_FREE_FLAG", "interestFreeFlag");
        obj.put("INTEREST_FREE_REASON","interestFreeReason");
        obj.put("FREE_MONEY","freeMoney");
        return obj;
    }
}